package com.dhl.fin.api.controller;

import com.dhl.fin.api.common.controller.CommonController;
import com.dhl.fin.api.common.dto.ApiResponse;
import com.dhl.fin.api.domain.BankAccount;
import com.dhl.fin.api.domain.LendRecord;
import com.dhl.fin.api.service.LendRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author CuiJianbo
 * @since 2025/4/25
 */

@RestController
@RequestMapping("lendrecord")
public class LendRecordController extends CommonController<LendRecord> {

    @Autowired
    private LendRecordService lendRecordService;

    @ResponseBody
    @GetMapping("allChildLendRecord")
    public ApiResponse queryAllChildLendRecord() throws Exception {
        List<BankAccount> bankAccounts = lendRecordService.queryAllChildLendRecord();
        return ApiResponse.success(bankAccounts);
    }

    @ResponseBody
    @GetMapping("repay")
    public ApiResponse repay(Integer money, Long recordId, Long accountId) throws Exception {
         lendRecordService.repayLendMoney(money, recordId, accountId);
        return ApiResponse.success();
    }


}
